package com.indexingsystem.system.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.indexingsystem.boss.admin.mapper.TokensMapper;
import com.indexingsystem.boss.common.PagedResult;
import com.indexingsystem.boss.entity.Tokens;
import com.indexingsystem.boss.utils.BeanUtils;
import com.indexingsystem.system.service.ITokensService;

@Service
public class TokenServiceImpl implements ITokensService{

	@Resource
	private TokensMapper tokensMapper;
	
	@Override
	public int deleteByPrimaryKey(String tokenId) {
		return tokensMapper.deleteByPrimaryKey(tokenId);
	}

	@Override
	public int insertSelective(Tokens record) {
		return tokensMapper.insertSelective(record);
	}

	@Override
	public Tokens selectByPrimaryKey(String tokenId) {
		return tokensMapper.selectByPrimaryKey(tokenId);
	}

	@Override
	public int updateByPrimaryKeySelective(Tokens record) {
		return tokensMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public PagedResult<Tokens> selectTokenList(Integer pageNo, Integer pageSize) {
		pageNo = pageNo == null?1:pageNo;
		pageSize = pageSize == null?10:pageSize;
		//startPage是告诉拦截器说我要开始分页了。分页参数是这两个。
		PageHelper.startPage(pageNo,pageSize);  
		return BeanUtils.toPagedResult(tokensMapper.selectTokenList());
	}
}